package com.world.rickcloudendpoint.basic;

/**
 * @description: 抽象服务基类
 * @author: jlsong
 * @date: 2021/12/22 20:50:56
 * @version: 1.0
 */
public abstract class AbstractServerService implements IServerService {

    private final String serviceId;
    protected byte serviceState;

    public AbstractServerService(String serviceId) {
        this.serviceId = serviceId;
    }

    @Override
    public final String getId() {
        return serviceId;
    }

    @Override
    public boolean initialize() {
        // 从全局服务管理器注册自己
        ServerServiceManager.getInstance().registerService(serviceId, this);
        return true;
    }

    @Override
    public void release() {
        // 从全局服务管理器移除自己
        ServerServiceManager.getInstance().removeService(serviceId);
    }

    @Override
    public final byte getState() {
        return serviceState;
    }

    @Override
    public final boolean isRunning() {
        return true;
    }

    @Override
    public void startup() throws Exception {

    }

    @Override
    public void shutdown() throws Exception {

    }
}
